package com.vancouver.knows.business.tracker;

import com.pangu.task.IResultReceiver;
import com.pangu.task.OperateResult;
import com.vancouver.knows.business.BSharedPrefManager;
import com.vancouver.knows.business.BusinessModule;
import com.vancouver.knows.business.bean.UserInfo;

public class ChangeUserImagerTracker extends ABInvokeTracker {

	public ChangeUserImagerTracker(BusinessModule module, IResultReceiver resultReceiver) {
		super(module, resultReceiver);
	}

	@Override
	public String TAG() {
		return ChangeUserImagerTracker.class.getSimpleName();
	}

	@Override
	public void handleResult(OperateResult result) {
		UserInfo userInfo = (UserInfo) result.getResultData();
		if (userInfo == null)
			return;
		BSharedPrefManager sharedPrefManager = new BSharedPrefManager(imContext);
		sharedPrefManager.saveUserId(userInfo.getUserID());
		sharedPrefManager.saveUserName(userInfo.getName());
		sharedPrefManager.saveUserEmail(userInfo.getEmail());
		if (userInfo.getAvatar() == null) {
			sharedPrefManager.saveAvatar(userInfo.getUserMeta().getAvatar());
		} else {
			sharedPrefManager.saveAvatar(userInfo.getAvatar());
		}
		sharedPrefManager.saveAvatar(userInfo.getAvatar());
		sharedPrefManager.saveLogin(userInfo.getLogin());
		
		//"total_unread_comment":0,
		//"total_unread_post_comment":1,
		//更换头像时没有跟新这两项，可以在BSharedPrefManager类中调用原来存储的值
		module.getCacheManager().setUserInfo(userInfo);
	}

}
